-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Remove square brackets from ipv6 host on PostgreSQL and refactor changes from PR 310 #316
[3.x] Remove square brackets from ipv6 host on PostgreSQL and refactor changes from PR 310 #316
Conversation
Do not change `$this->options` inside method but use arguments and return array extracted host, port and socket. Rename the method to reflect this change. Early return in case of socket.
@alikon @Hackwar @HLeithner @muhme and possible other other reviewers: Please check the "Request for comments - RFC" section in the description and let me know your opinion. Thanks in advance. |
Running System Tests with current
Failed for
|
Hmm the MySQLi and the PDO driver set the host to „localhost“ in the constructor, so a null host value should never happen. |
Will check later why that fails. |
To verify, I created a new installation using the |
Yes, I know what the problem is. The method can run multiple times when connecting for checking the database and then disconnecting and connecting again to make the installation. In the old code before PR #310 the Now we have a function where the parameter is not nullable. There are 2 ways to solve it: Either I do it like for PDO and do not modify the I tend to the first way. The real clean way would be to use the method not in the connect method but in the constructor so it would run only one time on a particular instance. |
Hmm, on the other hand, the 2nd way would make it behave on MySQL like it was before PR #310 . |
@muhme Fixed. Thanks for testing so far. |
✅ Successfully completed the test with all 9 steps again, confirming that all tests passed smoothly this time. 👍 |
I have some questions.
wouldn't this reduce a bit of complexity? at least I read somewhere something about double decode issue. |
@HLeithner Regarding your question 2: I don’t know why it is done in the connect method. It was like that since long time, if not since ever, when I checked the history on the 1.0-dev branch. I did not want to change that in a patch version. I fully agree that it should be done in the constructor. If there is consensus about that I can change this PR here (or make a new one). Regarding question 1: Same reason as question 2, I did not want to make such a big change now. We could discuss that in the next maintainers meeting for framework topics. |
I've created an alternative PR which makes the same changes as this one here (except of adding a unit test) plus moves the modification of options from the connect method to the constructor. Closing in favour of #317 . Thanks for feedback and tests. |
Pull Request for Issue #
Alternative to #315 .
Summary of Changes
This pull request (PR) adds an option to the
setHostPortSocket
method, which was added with PR #310 , to control if the square brackets around an IP v6 address in thehost
parameter should be kept ("MySQLi" and "MySQL (PDO)") or if they should be removed ("PostgreSQL (PDO)") in the connection parameters.The default is true to keep the square brackets. For "PosgreSQL (PDO)" it is set to false so the quare brackets are removed.
This makes it possible to specify an IP v6 address together with a port number for "PostgreSQL (PDO)" in the same way as it already works for "MySQLi" and "MySQL (PDO)".
See also PR #315 for details.
In addition, this PR changes the
setHostPortSocket
method to not implicitly modify$this->options
but to use function parameters and return value, and it renames that method toextractHostPortSocket
to reflect that change.The change to use function parameters and a return value makes it easier to provide unit tests for that method.
In the PDO driver, the original options are not modified but local variables are used. This makes sure that the options are not modified multiple times with each re-connect, which would cause problems with the removal of square brackets because the colons in an IP v6 address would cause wrong port number to be detected at the 2nd run.
In the MySQL driver this PR keeps it like it was so the behaviour is like before.
Finally, this PR adds a unit test for the
extractHostPortSocket
method.Request for comments - RFC
As the
extractHostPortSocket
method is protected, the unit test uses reflection to make it accessible.An alternative would be to change that method to public.
@alikon @Hackwar @HLeithner @muhme and other reviewers: What do you think? Leave the unit test as it is? Or make the method public and test it without reflection?
Testing Instructions
See CMS issue joomla/joomla-cms#43902 and joomla-projects/joomla-cypress#36 ,
And check in unit test logs in Drone if they contain a successful test "Pure host name or IP address and port or socket can be extracted from the host name option".
Documentation Changes Required
Don't know.